home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Comms & Internet / LinkConverter 1.1.2 / Dialog Director v0.7 / Examples / Icon Buttons.as < prev    next >
Encoding:
Text File  |  1998-01-24  |  3.7 KB  |  70 lines  |  [TEXT/ToyS]

  1. -- ••• NOTE: Drop this script file on ResEdit to see the icons used •••
  2.  
  3. set y to 420
  4. set iconNo to 200
  5. set theDialog to {style:standard window, name:"Icon Buttons Demo", size:[576, y + 30], contents:[¬
  6.     {class:push button, bounds:[506, y, 566, y + 20], name:"OK"}, ¬
  7.     {class:check box, bounds:[400, y, 480, y + 20], name:"Enabled", value:true}] ¬
  8.     & MakeGroup(icon push button, "Push Buttons", 20, 30, 22, 22, 200, IFlags(1, 1), 4, 2) ¬
  9.     & MakeGroup(icon radio button, "Radio Buttons", 171, 30, 22, 22, 207, IFlags(1, 1), 4, 2) ¬
  10.     & MakeGroup(icon toggle button, "Toggle Buttons", 321, 30, 22, 22, 214, IFlags(1, 1), 4, 2) ¬
  11.     & MakeGroup(icon sticky button, "Sticky Buttons", 472, 30, 22, 22, 203, IFlags(1, 1), 4, 2) ¬
  12.     & MakeGroup(icon push button, "Big Push Buttons", 20, 110, 40, 40, 200, IFlags(0, 2), 3, 2) ¬
  13.     & MakeGroup(icon radio button, "Big Radio Buttons", 161, 110, 40, 40, 205, IFlags(0, 2), 3, 2) ¬
  14.     & MakeGroup(icon toggle button, "Big Toggle Buttons", 302, 110, 40, 40, 210, IFlags(0, 2), 3, 2) ¬
  15.     & MakeGroup(icon sticky button, "Big Sticky Buttons", 443, 110, 40, 40, 216, IFlags(0, 2), 3, 2) ¬
  16.     & MakeGroup(icon toggle button, "Wide Buttons", 20, 230, 28, 20, 200, IFlags(1, 1), 3, 2) ¬
  17.     & MakeGroup(icon toggle button, "Thin Buttons", 130, 230, 20, 28, 200, IFlags(1, 1), 4, 2) ¬
  18.     & MakeGroup(icon toggle button, "High …", 240, 230, 26, 26, 200, IFlags(1, 3), 2, 2) ¬
  19.     & MakeGroup(icon toggle button, "… Medium …", 320, 230, 22, 22, 200, IFlags(1, 2), 3, 2) ¬
  20.     & MakeGroup(icon toggle button, "… Low …", 413, 230, 20, 20, 200, IFlags(1, 1), 3, 2) ¬
  21.     & MakeGroup(icon toggle button, "… and Flat", 500, 230, 20, 20, 200, IFlags(1, 0), 3, 2) ¬
  22.     & MakeGroup(icon toggle button, "Small Icons on Big Buttons", 20, 320, 40, 40, 200, IFlags(1, 3), 4, 2) ¬
  23.     & MakeGroup(icon toggle button, "Single", 210, 320, 40, 40, 200, IFlags(1, 3), 1, 1) ¬
  24.     & MakeGroup(icon toggle button, "No Icon", 290, 320, 40, 40, -1, IFlags(1, 3), 1, 1) ¬
  25.     & MakeGroup(icon push button, "Changing", 370, 320, 60, 58, iconNo, IFlags(0, 3), 1, 1) ¬
  26.     & MakeGroup(icon toggle button, "Mini-Icons", 470, 320, 20, 20, 200, IFlags(2, 1), 4, 3) ¬
  27.     & [¬
  28.     {class:group box, bounds:[200, 380, 303, 433], name:"Interdependent", enabled:2}, ¬
  29.     {class:icon toggle button, bounds:[210, 400, 232, 422], contents:221, style:IFlags(1, 1), enabled:[dAnd, 2, -139, -140]}, ¬
  30.     {class:icon toggle button, bounds:[240, 400, 262, 422], contents:218, style:IFlags(1, 1), enabled:[dAnd, 2, -138, -140]}, ¬
  31.     {class:icon toggle button, bounds:[270, 400, 292, 422], contents:217, style:IFlags(1, 1), enabled:[dAnd, 2, -138, -139]}, ¬
  32.     {class:static text, bounds:[10, y + 2, 200, y + 20], contents:""} ¬
  33.         ]}
  34.  
  35. dd install with fonts [null, null, {name:"Geneva", size:9, style:bold}] with grayscale
  36. set d1 to dd make dialog theDialog
  37. dd set value of item 14 of d1 to (true)
  38. dd set value of item 47 of d1 to (true)
  39. repeat
  40.     set i to dd interact with user
  41.     if i = 1 then
  42.         exit repeat
  43.     else if i = 123 then
  44.         set iconNo to iconNo + 1
  45.         if iconNo > 222 then set iconNo to 200
  46.         dd set contents of item 123 of d1 to iconNo
  47.     end if
  48.     dd set contents of last item of d1 to "Item Pressed: " & i
  49. end repeat
  50. --set dVals to dd get value of every item of d1
  51. dd uninstall
  52. --dVals
  53.  
  54. on IFlags(iconSize, border)
  55.     return iconSize + border * 4
  56. end IFlags
  57.  
  58. on MakeGroup(ibClass, gName, x, y, w, h, iconID, iStyle, nAcross, nDown)
  59.     set g to [{class:group box, bounds:[x - 10, y - 20, x + (w - 1) * nAcross + 12, y + (h - 1) * nDown + 12], name:gName, enabled:2}]
  60.     repeat nDown times
  61.         set x1 to x
  62.         repeat nAcross times
  63.             set g to g & [{class:ibClass, bounds:[x1, y, x1 + w, y + h], contents:iconID, style:iStyle, enabled:2}]
  64.             set x1 to x1 + w - 1
  65.             set iconID to iconID + 1
  66.         end repeat
  67.         set y to y + h - 1
  68.     end repeat
  69.     return g
  70. end MakeGroup